/****************************************************************************
**
**	File Name	: MD5.h
**
**	Project     : RideEx
**
**	Last Updated: Tue 25 Mar '03
**	          by: ,,,^..^,,,
**
**	This code is "derived from the RSA Data Security, Inc. MD5 Message-
**	Digest Algorithm", and must include the following information:
+---------------------------------------------------------------------------+
|	Copyright (C) 1990, RSA Data Security, Inc. All rights reserved.		|
|																			|
|	License to copy and use this software is granted provided that it is	|
|	identified as the "RSA Data Security, Inc. MD5 Message-Digest 			|
|	Algorithm" in all material mentioning or referencing this software or	|
|	this function.															|
|																			|
|	License is also granted to make and use derivative works provided that  |
|	such works are identified as "derived from the RSA Data Security, Inc.	|
|	MD5 Message-Digest Algorithm" in all material mentioning or referencing	|
|	the derived work.                                 						|
|																			|
|	RSA Data Security, Inc. makes no representations concerning either the  |
|	merchantability of this software or the suitability of this software	|
|	for any particular purpose.  It is provided "as is" without express or	|
|	implied warranty of any kind.											|
|																			|
|	These notices must be retained in any copies of any part of this		|
|	documentation and/or software.											|
+---------------------------------------------------------------------------+
**
**	Change Log	: $Header: /DatChecker.root/DatChecker/MD5.h 1     8/14/03 9:25a Neusel $
**
**		Date		 Version	Reason
**		====		 =======	======
**	Tue 25 Mar '03		1.00	Initial design & coding
**
****************************************************************************/
#pragma once
#ifndef	__H_MD5
	#define __H_MD5
/*	-----------------------------------------------------------------------
	MD5 Class Declaration -- see MD5.cpp for implementation
	-----------------------------------------------------------------------	*/
class MD5
	{
public:
	enum				{ kDigestLen = 16 };

	typedef BYTE		Digest[kDigestLen];
/*
**	Variables
*/
protected:
	Digest				m_digest;
	BYTE				m_cInput[64];		// input buffer
	DWORD				m_dwBits[2],		// # of bits handled mod 2^64
						m_dwBuffer[4];		// scratch buffer
public:
/*
**	Methods
*/
protected:
	void				transform(const DWORD []);
public:
	static LPCTSTR		ConvertToASCII(const MD5::Digest);

	void				Start(void);
	void				Stop(void);
	void				Update(BYTE const *, DWORD);

// INLINES
	static int			Compare(const MD5::Digest digestLHS, const MD5::Digest digestRHS)
							{ return memcmp(digestLHS, digestRHS, sizeof(Digest)); }
							 
	int					Compare(const MD5::Digest digest) const
							{ return memcmp(digest, m_digest, sizeof(Digest)); }
// GETTERS & SETTERS
	void				GetDigest(MD5::Digest digest) const
							{ ::CopyMemory(digest, m_digest, sizeof(Digest)); }
	LPCTSTR				GetDigestStr(void) const
							{ return ConvertToASCII(m_digest); }

//	CTOR/DTOR
						MD5(void)
							{ Start(); }
	virtual				~MD5(void)
							{ /* STUB FUNCTION */ }
//	DO NOT IMPLEMENT:
private:
						MD5(const MD5 &);		// copy CTOR
	MD5 &				operator=(const MD5 &);	// assignment
	};

#endif	//	__H_MD5
/****************************************************************************
**
**	End of MD5.h
**
****************************************************************************/
